package com.newenergy.wisehome.common.manager;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by jnl on 2017/9/18.
 */

public class MyThreadManager {

    private final ExecutorService mCachedThreadPool;

    static class Wrapper {
        private static MyThreadManager instance;

        static {
            instance = new MyThreadManager();
        }
    }


    public static MyThreadManager getInstance() {

        return Wrapper.instance;
    }

    private MyThreadManager() {
        mCachedThreadPool = Executors.newCachedThreadPool();
    }


    public void doTask(Runnable runnable) {
        mCachedThreadPool.execute(runnable);
    }

    public void cancelTask(Runnable runnable) {
        mCachedThreadPool.shutdown();
    }
}
